package com.bwei.like.mynewstop.app;

import android.app.Application;
import android.content.Context;
import android.os.Handler;
import android.os.Process;

import com.bwei.like.mynewstop.utils.ImageLoaderUtils;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;

import org.xutils.x;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import cn.smssdk.EventHandler;
import cn.smssdk.SMSSDK;

/**
 * Created by LiKe on 2016/10/31.
 */
public class MyApplication extends Application {

    private static Context context;
    private static Handler handler;
    private static int mainThreadId;
    private static Thread currentThread;
    private static ExecutorService executorService;
    public static boolean showChnanelLongListener = false;


    @Override
    public void onCreate() {
        super.onCreate();
        //获取上下文
        context = getApplicationContext();
        //获取handler
        handler = new Handler();
        //获取主线程id
        mainThreadId = Process.myTid();
        //获取当前线程
        currentThread = Thread.currentThread();
        //创建线程池
        executorService = Executors.newFixedThreadPool(5);
        //初始化Xutils
        x.Ext.init(this);
        //设置debug模式
        x.Ext.setDebug(true);
        ImageLoaderUtils.initConfiguration(getApplicationContext());

        //短信

        SMSSDK.initSDK(this, "18cbdd7ac1644", "e9679e8eb23efbd950d6900b0e59edad");

        //QQ
        PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
        PlatformConfig.setSinaWeibo("3921700954", "04b48b094faeb16683c32669824ebdad");
        UMShareAPI.get(this);
    }

    public static ExecutorService getThreadPoll() {
        return executorService;
    }

    public static Thread getMainThread(){
        return currentThread;
    }

    public static int getMainThreadId(){
        return mainThreadId;
    }

    public static Handler getHandler(){
        return handler;
    }

    public static Context getContext(){
        return context;
    }
}
